<template>
  <tr>
      <td>
          <input type="checkbox" v-model="obj.checked">
      </td>
      <td>{{obj.name}}</td>
      <td>{{obj.price}}</td>
      <td>
          <button @click="sub" :disabled = 'obj.num == 1'>-</button>
          <span>1</span>
          <button @click="add">+</button>
      </td>
      <td>{{obj.num * obj.price}}</td>
      <td>
          <button @click="delFn">删除</button>
      </td>
  </tr>
</template>

<script>
export default {
props: ['obj',"index"],
methods: {
    add(){
        this.obj.num++;
    },
    sub(){
         this.obj.num--
    },
    delFn(){
        this.$emit('sub',this.index)
    }
}
}
</script>

<style>

</style>